//导入axios
import axios from 'axios'
import store from '@/store/index.js'
// 配置请求的基准URL地址
axios.defaults.baseURL = 'http://1.92.82.82:3001/'
// axios设置请求拦截器,设置响应头token

axios.interceptors.request.use(
  config => {
	  let token=store.state.token;
	  if(!store.state.token){
	  	token=localStorage.getItem('token')
	  }
    // config.headers.token = window.sessionStorage.getItem('token') //每次发送请求之前自动将在session中的token提取出来当做响应头header
       config.headers.token =token;
    return config
  },
  err => {
    console.log(err)
  }
)


// 导出axios
export default axios;
